package com.spring.mvc.controller.formatter;

import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author 28593
 * @auther 尚智江
 * @Date 2022/10/27 9:29
 */
@Component
public class MyFormatter implements Formatter<Date> {

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    @Override
    public String print(Date object, Locale locale) {
        return dateFormat.format(object);
    }
    @Override
    public Date parse(String source, Locale locale) throws ParseException {
        return dateFormat.parse(source);
    }


}
